
public class test1 {
    public boolean isValidBST(TreeNode root) {
        return getResult(root,Integer.MIN_VALUE,Integer.MAX_VALUE);
    }
    public boolean getResult(TreeNode root,int min,int max){
        if(root==null){
            return true;
        }
        if(root.val<=min||root.val>=max)
            return false;
        return getResult(root.left,min,root.val)&&getResult(root.right,root.val,max);
    }
}
